request({
    url: 'data/assets/list.json',
    success: function(data) {
        // 显示总资产
        var total = data.total;
        
        $('#total').html(thousandth(total) + '<span>.' + decimalFormat(total,2) + '</span>');

        // 显示资产变化
        var change = data.change;
        var changeValue = '';

        if (change.type == 1) {
            changeValue = '+';
        } else {
            changeValue = '-';
        }

        changeValue += thousandth(change.value);

        $('#changeValue').text(changeValue);



        // 显示资产列表
        var list = data.list,
            html = [];

        for (var i = 0, len = list.length; i < len; i++) {
            var item = list[i];
            var value = '';

            if (item.value > 0) {
                value = '<span>' + item.value + '</span>' + item.unit;
            } else {
                value = '<span>+</span>';
            }

            html.push('<li class="touch asset-item" addurl="' + item.addUrl + '">\
			            <h3>' + item.name + '</h3>\
			            <p>' + value + '</p>\
			        </li>');
        }

        var $assetsList = $('#assetsList');
        $assetsList.append(html.join(''));

        // 绑定资产列表事件
        $assetsList.find('.asset-item').on('click', function() {
            // 事件函数代理
            // 闭包
            clickAssetsItem($assetsList, this);
        });

    }
});


function clickAssetsItem($list, self) {
    // 获取当前点击的li
    var $self = $(self);
    var addUrl = $self.attr('addurl');

    location.href = addUrl;
}













//